package com.ldu.houserent.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ldu.houserent.entity.User;
import com.ldu.houserent.mapper.UserMapper;
import com.ldu.houserent.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/*
    用户服务接口实现类
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;      //实例化接口

    //mapper对象
    @Override
    public BaseMapper<User> getRepository() {       //获取数据库，即获取mapper对象
        return userMapper;
    }

    //获取查询器
    @Override
    public QueryWrapper<User> getQueryWrapper(User user) {      //QueryWrapper ： Entity 对象封装操作类
        return null;
    }

    //获取带参数的查询器
    @Override
    public QueryWrapper<User> getQueryWrapper(Map<String, Object> condition) {
        return null;
    }

    //根据用户名查询用户是否存在
    @Override
    public User findByUserName(String userName) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("user_name",userName);      //根据userName查一条数据，看是否能够查到   等同于select * from t_user where user_name=?
        return userMapper.selectOne(queryWrapper);
    }
}
